package com.mt.demo.controller;

import com.mt.demo.domain.AjaxResult;
import com.mt.demo.domain.MtVote;
import com.mt.demo.domain.TableDataInfo;
import com.mt.demo.service.IMtVoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 投票主Controller
 * 
 * @author gary
 * @date 2025-08-11
 */
@RestController
@RequestMapping("/mt/mtVote")
public class MtVoteController extends BaseController
{
    @Autowired
    private IMtVoteService mtVoteService;

    /**
     * 查询投票主列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MtVote mtVote)
    {
        startPage();
        List<MtVote> list = mtVoteService.selectMtVoteList(mtVote);
        return getDataTable(list);
    }

    /**
     * 导出投票主列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, MtVote mtVote)
    {
        List<MtVote> list = mtVoteService.selectMtVoteList(mtVote);
//        ExcelUtil<MtVote> util = new ExcelUtil<MtVote>(MtVote.class);
//        util.exportExcel(response, list, "投票主数据");
    }

    /**
     * 获取投票主详细信息
     */
    @GetMapping(value = "/{voteId}")
    public AjaxResult getInfo(@PathVariable("voteId") Long voteId)
    {
        return success(mtVoteService.selectMtVoteByVoteId(voteId));
    }

    /**
     * 新增投票主
     */
    @PostMapping
    public AjaxResult add(@RequestBody MtVote mtVote)
    {
        return toAjax(mtVoteService.insertMtVote(mtVote));
    }

    /**
     * 修改投票主
     */
    @PutMapping
    public AjaxResult edit(@RequestBody MtVote mtVote)
    {
        return toAjax(mtVoteService.updateMtVote(mtVote));
    }

    /**
     * 删除投票主
     */
	@DeleteMapping("/{voteIds}")
    public AjaxResult remove(@PathVariable Long[] voteIds)
    {
        return toAjax(mtVoteService.deleteMtVoteByVoteIds(voteIds));
    }
}
